<template>
    <div class="hr-rlda">
      <Layout :style="{padding: '0 24px 24px'}">
        <Breadcrumb :style="{margin: '24px 0'}">
          <BreadcrumbItem><a href="javascript:void(0)" @click="jump('/index')">首页</a></BreadcrumbItem>
          <BreadcrumbItem>人力资源管理</BreadcrumbItem>
          <BreadcrumbItem>人力档案</BreadcrumbItem>
        </Breadcrumb>
        <Content :style="{padding: '24px', minHeight: '280px', background: '#fff'}">
          <div class="hr-header" ghost>
            <div class="hr-header-search">
              <span>搜索条件：</span>
              <Input v-model="search" placeholder="请输入员工姓名..." style="width: 300px"></Input>
              <Button @click="toSearch"><Icon type="md-search" />搜索</Button>
            </div>
            <Button @click="addDrawer=true"><Icon type="md-add" />新增</Button>
            <Button @click="toRefresh"><Icon type="md-sync" />刷新</Button>
          </div>
          <div class="hr-content">
            <Table :loading="loading" :height="666"  :columns="tb_columns" :data="staff_list" size="small"></Table>
            <Page :total="staff_total" :current="staff_current_page" :page-size="staff_page_size" @on-change="onChange" @on-page-size-change="onPageSizeChange" show-total show-sizer size="small" style="float:right;margin-top:12px"/>
          </div>
        </Content>
      </Layout>
      <Drawer title="新增员工档案" :closable="false" v-model="addDrawer" width="70" :mask-closable="false">
        <Form ref="addForm" :model="addForm" :rules="addRuleVal" :label-width="120">
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="姓名：" prop="name">
                <Input v-model="addForm.name" placeholder="请输入员工姓名..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="性别：" prop="gender">
                <RadioGroup v-model="addForm.gender">
                  <Radio label="男">男</Radio>
                  <Radio label="女">女</Radio>
                </RadioGroup>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="在职情况：" prop="flag">
                <RadioGroup v-model="addForm.flag">
                  <Radio label="在职">在职</Radio>
                  <Radio label="离职">离职</Radio>
                </RadioGroup>
              </FormItem>
            </Col>
            <Col span="12" v-if="addForm.flag==='离职'">
              <FormItem label="离职时间：" prop="resignationTime">
                <DatePicker type="date" placeholder="请选择离职时间..." v-model="addForm.resignationTime"    style="width: 100%"></DatePicker>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="民族：" prop="nation">
                <Input v-model="addForm.nation" placeholder="请输入民族..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="出生日期：" prop="birthDate">
                <DatePicker type="date" placeholder="请选择出生日期..." v-model="addForm.birthDate"    style="width: 100%"></DatePicker>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="身份证号码：" prop="identityCerdNumber">
                <Input v-model="addForm.identityCerdNumber" placeholder="请输入身份证号码..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="婚姻状况：" prop="maritalStatus">
                <Select v-model="addForm.maritalStatus" placeholder="请选择婚姻状况...">
                  <Option value="已婚">已婚</Option>
                  <Option value="未婚">未婚</Option>
                </Select>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="入职时间：" prop="entryTime">
                <DatePicker type="date" placeholder="请选择入职时间..." v-model="addForm.entryTime"   style="width: 100%"></DatePicker>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="籍贯：" prop="nativePlace">
                  <Input v-model="addForm.nativePlace" placeholder="请输入籍贯..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="所在职位：" prop="position">
                <Select v-model="addForm.position" placeholder="请选择所在职位...">
                  <Option v-for="(item,key) in postSet_list" :key="key" :value="item.postName">{{item.postName}}</Option>
                </Select>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="所在部门：" prop="department">
                  <Input v-model="addForm.department" placeholder="请输入所在部门..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="政治面貌：" prop="politicsStatus">
                <Select v-model="addForm.politicsStatus" placeholder="请选择政治面貌...">
                  <Option value="群众">群众</Option>
                  <Option value="中共党员/预备党员">中共党员/预备党员</Option>
                  <Option value="其它">其它</Option>
                </Select>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="最高学历：" prop="highestEducation">
                <Select v-model="addForm.highestEducation" placeholder="请选择最高学历...">
                  <Option value="无">无</Option>
                  <Option value="小学">小学</Option>
                  <Option value="中学">中学</Option>
                  <Option value="高中">高中</Option>
                  <Option value="大专">大专</Option>
                  <Option value="本科">本科</Option>
                  <Option value="硕士">硕士</Option>
                  <Option value="博士">博士</Option>
                </Select>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="毕业院校：">
                <Input v-model="addForm.williamsCollege" placeholder="请输入毕业院校..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="专业：">
                <Input v-model="addForm.major" placeholder="请输入专业..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="联系电话：" prop="phone">
                <Input v-model="addForm.phone" placeholder="请输入联系电话..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="QQ号：">
                <Input v-model="addForm.qq" placeholder="请输入QQ号..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="微信号：">
                <Input v-model="addForm.weichat" placeholder="请输入微信号..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="邮箱：">
                <Input v-model="addForm.email" placeholder="请输入邮箱..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="现住址：">
                <Input v-model="addForm.presentAddress" placeholder="请输入现住址..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="户口所在地：" prop="domicilePlace">
                <Input v-model="addForm.domicilePlace" placeholder="请输入户口所在地..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="劳动合同签订时间：" prop="signingDate">
                <DatePicker type="date" placeholder="请选择劳动合同签订时间..." v-model="addForm.signingDate"    style="width: 100%"></DatePicker>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="合同签订时长：" prop="signingTime">
                <Input v-model="addForm.signingTime" placeholder="请输入劳动合同签订时长..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="24">
              <div style="text-align: right;border-top: 1px solid #e8e8e8;padding: 16px 16px 0 16px;">
                <Button type="primary" @click="handleSubmit('addForm')">提交</Button>
                <Button @click="handleReset('addForm')" style="margin-left: 8px">取消</Button>
              </div>
            </Col>
          </Row>
        </Form>
      </Drawer>
      <Drawer title="更新员工档案信息" :closable="false" v-model="updateDrawer" width="70" :mask-closable="false">
        <Form ref="updateForm" :model="addForm" :rules="addRuleVal" :label-width="120">
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="姓名：" prop="name">
                <Input v-model="addForm.name" placeholder="请输入员工姓名..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="性别：" prop="gender">
                <RadioGroup v-model="addForm.gender">
                  <Radio label="男">男</Radio>
                  <Radio label="女">女</Radio>
                </RadioGroup>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="在职情况：" prop="flag">
                <RadioGroup v-model="addForm.flag">
                  <Radio label="在职">在职</Radio>
                  <Radio label="离职">离职</Radio>
                </RadioGroup>
              </FormItem>
            </Col>
            <Col span="12" v-if="addForm.flag==='离职'">
              <FormItem label="离职时间：" prop="resignationTime">
                <DatePicker type="date" placeholder="请选择离职时间..." v-model="addForm.resignationTime"    style="width: 100%"></DatePicker>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="民族：" prop="nation">
                <Input v-model="addForm.nation" placeholder="请输入民族..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="出生日期：" prop="birthDate">
                <DatePicker type="date" placeholder="请选择出生日期..." v-model="addForm.birthDate"    style="width: 100%"></DatePicker>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="身份证号码：" prop="identityCerdNumber">
                <Input v-model="addForm.identityCerdNumber" placeholder="请输入身份证号码..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="婚姻状况：" prop="maritalStatus">
                <Select v-model="addForm.maritalStatus" placeholder="请选择婚姻状况...">
                  <Option value="已婚">已婚</Option>
                  <Option value="未婚">未婚</Option>
                </Select>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="入职时间：" prop="entryTime">
                <DatePicker type="date" placeholder="请选择入职时间..." v-model="addForm.entryTime"   style="width: 100%"></DatePicker>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="籍贯：" prop="nativePlace">
                <Input v-model="addForm.nativePlace" placeholder="请输入籍贯..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="所在职位：" prop="position">
                <Select v-model="addForm.position" placeholder="请选择所在职位...">
                  <Option v-for="(item,key) in postSet_list" :key="key" :value="item.postName">{{item.postName}}</Option>
                </Select>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="所在部门：" prop="department">
                <Input v-model="addForm.department" placeholder="请输入所在部门..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="政治面貌：" prop="politicsStatus">
                <Select v-model="addForm.politicsStatus" placeholder="请选择政治面貌...">
                  <Option value="群众">群众</Option>
                  <Option value="中共党员/预备党员">中共党员/预备党员</Option>
                  <Option value="其它">其它</Option>
                </Select>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="最高学历：" prop="highestEducation">
                <Select v-model="addForm.highestEducation" placeholder="请选择最高学历...">
                  <Option value="无">无</Option>
                  <Option value="小学">小学</Option>
                  <Option value="中学">中学</Option>
                  <Option value="高中">高中</Option>
                  <Option value="大专">大专</Option>
                  <Option value="本科">本科</Option>
                  <Option value="硕士">硕士</Option>
                  <Option value="博士">博士</Option>
                </Select>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="毕业院校：" prop="williamsCollege">
                <Input v-model="addForm.williamsCollege" placeholder="请输入毕业院校..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="专业：" prop="major">
                <Input v-model="addForm.major" placeholder="请输入专业..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="联系电话：" prop="phone">
                <Input v-model="addForm.phone" placeholder="请输入联系电话..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="QQ号：" prop="qq">
                <Input v-model="addForm.qq" placeholder="请输入QQ号..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="微信号：" prop="weichat">
                <Input v-model="addForm.weichat" placeholder="请输入微信号..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="邮箱：" prop="email">
                <Input type="email" v-model="addForm.email" placeholder="请输入邮箱..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="现住址：" prop="presentAddress">
                <Input v-model="addForm.presentAddress" placeholder="请输入现住址..."></Input>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="户口所在地：" prop="domicilePlace">
                <Input v-model="addForm.domicilePlace" placeholder="请输入户口所在地..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row :gutter="16">
            <Col span="12">
              <FormItem label="劳动合同签订时间：" prop="signingDate">
                <DatePicker type="date" placeholder="请选择劳动合同签订时间..." v-model="addForm.signingDate"    style="width: 100%"></DatePicker>
              </FormItem>
            </Col>
            <Col span="12">
              <FormItem label="合同签订时长：" prop="signingTime">
                <Input v-model="addForm.signingTime" placeholder="请输入劳动合同签订时长..."></Input>
              </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="24">
              <div style="text-align: right;border-top: 1px solid #e8e8e8;padding: 16px 16px 0 16px;">
                <Button type="primary" @click="handleSubmit2('updateForm')">提交</Button>
                <Button @click="handleReset('updateForm')" style="margin-left: 8px">取消</Button>
              </div>
            </Col>
          </Row>
        </Form>
      </Drawer>
    </div>

</template>

<script>
  import expandRow from './table-expand.vue';
  import {mapGetters,mapActions} from 'vuex';
  import {toGet,toPost} from "../../utils/MyAxios";
  import md5 from 'js-md5';
  export default {
        name: "hr-rlda",
        data() {
            return {
              loading:false,
              addForm:{},
              updateDrawer:false,
              addRuleVal:{
                name: [
                  { required: true, message: '请输入姓名', trigger: 'blur' }
                ],
                gender: [
                  { required: true, message: '请选择性别', trigger: 'blur' }
                ],
                nation: [
                  { required: true, message: '请输入民族', trigger: 'blur' }
                ],
                identityCerdNumber: [
                  { required: true, message: '请输入身份证号码', trigger: 'blur' }
                ],
                maritalStatus: [
                  { required: true, message: '请选择婚姻状况', trigger: 'blur' }
                ],
                flag: [
                  { required: true, message: '请选择在职情况', trigger: 'blur' }
                ],
                nativePlace: [
                  { required: true, message: '请输入籍贯', trigger: 'blur' }
                ],
                position: [
                  { required: true, message: '请选择所在职位', trigger: 'blur' }
                ],
                department: [
                  { required: true, message: '请输入所在部门', trigger: 'blur' }
                ],
                politicsStatus: [
                  { required: true, message: '请选择政治面貌', trigger: 'blur' }
                ],
                highestEducation: [
                  { required: true, message: '请选择最高学历', trigger: 'blur' }
                ],
                williamsCollege: [
                  { required: true, message: '请输入毕业院校', trigger: 'blur' }
                ],
                major: [
                  { required: true, message: '请输入专业', trigger: 'blur' }
                ],
                phone: [
                  { required: true, message: '请输入联系电话', trigger: 'blur' }
                ],
                qq: [
                  { required: true, message: '请输入QQ号', trigger: 'blur' }
                ],
                weichat: [
                  { required: true, message: '请输入微信号', trigger: 'blur' }
                ],
                email: [
                  { required: true, message: '请输入邮箱', trigger: 'blur' }
                ],
                presentAddress: [
                  { required: true, message: '请输入现住址', trigger: 'blur' }
                ],
                domicilePlace: [
                  { required: true, message: '请输入户口所在地', trigger: 'blur' }
                ],
                signingTime: [
                  { required: true, message: '请输入劳动合同签订时长', trigger: 'blur' }
                ],
              },
              addDrawer:false,
              search:'',
              tb_columns: [
                {
                  type: 'expand',
                  width: 50,
                  render: (h, params) => {
                    return h(expandRow, {
                      props: {
                        row: params.row
                      }
                    })
                  }
                },
                {
                  title: '档案编号',
                  key: 'id',
                  align: 'center'
                },
                {
                  title: '姓名',
                  key: 'name',
                  align: 'center'
                },
                {
                  title: '性别',
                  key: 'gender',
                  align: 'center'
                },
                {
                  title: '民族',
                  key: 'nation',
                  align: 'center'
                },
                {
                  title: '入职时间',
                  key: 'entryTime',
                  align: 'center'
                },
                {
                  title: '职位',
                  key: 'position',
                  align: 'center'
                },
                {
                  title: '联系电话',
                  key: 'phone',
                  align: 'center'
                },
                {
                  title: '现住址',
                  key: 'presentAddress',
                  align: 'center'
                },
                {
                  title: '劳动合同签订时间',
                  key: 'signingDate',
                  align: 'center'
                },
                {
                  title: '签订时长',
                  key: 'signingTime',
                  align: 'center'
                },
                {
                  title: '操作',
                  align: 'center',
                  render: (h, params) => {
                    return h('div', [
                        h('Button', {
                          props: {
                            icon: 'md-create',
                            size: 'small'
                          },
                          style: {
                            color: 'black',
                          },
                          on: {
                            click: () => {
                              this.toUpdate(params.row.id)
                            }
                          }
                        }),
                        h('Button', {
                          props: {
                            icon: 'md-trash',
                            size: 'small'
                          },
                          style: {
                            color: 'black',
                          },
                          on: {
                            click: () => {
                              this.toDel(params.row.id)
                            }
                          }
                        })
                    ]);
                  }
                }
              ],
            }
        },
        computed: {
          ...mapGetters(['staff_list','staff_total','staff_current_page','staff_page_size','postSet_list']),
        },
        methods: {
          ...mapActions(['getStaffList','getPostSetList']),
          toRefresh(){
            this.getStaffList({
              'search':this.search,
              'currentPage':this.staff_current_page,
              'pageSize':this.staff_page_size
            });
          },
          handleSubmit (name) {
            this.$refs[name].validate((valid) => {
              if (valid) {
                  this.loading=true;
                if(this.addForm.birthDate){
                  let date = new Date(this.addForm.birthDate);
                  this.addForm.birthDate=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
                }
                if(this.addForm.entryTime){
                  let date = new Date(this.addForm.entryTime);
                  this.addForm.entryTime=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
                }
                if(this.addForm.signingDate){
                  let date = new Date(this.addForm.signingDate);
                  this.addForm.signingDate=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
                }
                  let params = {
                    name:this.addForm.name,
                    gender:this.addForm.gender,
                    nation:this.addForm.nation,
                    birthDate:this.addForm.birthDate,
                    entryTime:this.addForm.entryTime,
                    signingDate:this.addForm.signingDate,
                    identityCerdNumber:this.addForm.identityCerdNumber,
                    maritalStatus:this.addForm.maritalStatus,
                    nativePlace:this.addForm.nativePlace,
                    position:this.addForm.position,
                    department:this.addForm.department,
                    politicsStatus:this.addForm.politicsStatus,
                    highestEducation:this.addForm.highestEducation,
                    williamsCollege:this.addForm.williamsCollege,
                    major:this.addForm.major,
                    phone:this.addForm.phone,
                    qq:this.addForm.qq,
                    weichat:this.addForm.weichat,
                    email:this.addForm.email,
                    presentAddress:this.addForm.presentAddress,
                    domicilePlace:this.addForm.domicilePlace,
                    signingTime:this.addForm.signingTime,
                    resignationTime:this.addForm.resignationTime,
                    flag:this.addForm.flag,
                  };
                  toPost('/human-resources/hr/staff/add',params)
                    .then(res=>{
                      if (res.resultCode === 0) {
                        this.$Notice.success({
                          title: '新增员工档案成功'
                        });
                        this.$refs[name].resetFields();
                        this.toRefresh();
                        this.addDrawer=false;
                      }else{
                        this.$Notice.error({
                          title: '新增员工档案失败',
                          desc: '服务器发生未知错误'
                        })
                      }
                    });
                  this.loading=false;
              }
            })
          },
          handleSubmit2 (name) {
            this.$refs[name].validate((valid) => {
              if (valid) {
                  this.loading=true;
                  if(this.addForm.birthDate){
                    let date = new Date(this.addForm.birthDate);
                    this.addForm.birthDate=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
                  }
                  if(this.addForm.entryTime){
                    let date = new Date(this.addForm.entryTime);
                    this.addForm.entryTime=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
                  }
                  if(this.addForm.signingDate){
                    let date = new Date(this.addForm.signingDate);
                    this.addForm.signingDate=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
                  }
                  let params = {
                    id:this.addForm.id,
                    name:this.addForm.name,
                    gender:this.addForm.gender,
                    nation:this.addForm.nation,
                    birthDate:this.addForm.birthDate,
                    entryTime:this.addForm.entryTime,
                    signingDate:this.addForm.signingDate,
                    identityCerdNumber:this.addForm.identityCerdNumber,
                    maritalStatus:this.addForm.maritalStatus,
                    nativePlace:this.addForm.nativePlace,
                    position:this.addForm.position,
                    department:this.addForm.department,
                    politicsStatus:this.addForm.politicsStatus,
                    highestEducation:this.addForm.highestEducation,
                    williamsCollege:this.addForm.williamsCollege,
                    major:this.addForm.major,
                    phone:this.addForm.phone,
                    qq:this.addForm.qq,
                    weichat:this.addForm.weichat,
                    email:this.addForm.email,
                    presentAddress:this.addForm.presentAddress,
                    domicilePlace:this.addForm.domicilePlace,
                    signingTime:this.addForm.signingTime,
                    resignationTime:this.addForm.resignationTime,
                    flag:this.addForm.flag,
                  };
                  toPost('/human-resources/hr/staff/update',params)
                    .then(res=>{
                      if (res.resultCode === 0) {
                        this.$Notice.success({
                          title: '修改员工档案信息成功'
                        });
                        this.$refs[name].resetFields();
                        this.toRefresh();
                        this.updateDrawer=false;
                      }else{
                        this.$Notice.error({
                          title: '修改员工档案信息失败',
                          desc: '服务器发生未知错误'
                        })
                      }
                    });
                  this.loading=false;
              }
            })
          },
          handleReset (name) {
            this.addDrawer=false;
            this.updateDrawer=false;
            this.$refs[name].resetFields();
          },
          onChange(currentPage){
            this.getStaffList({
              'search':this.search,
              'currentPage':currentPage*1,
              'pageSize':this.staff_page_size
            });
          },
          jump(e){
            this.$router.push(e);
          },
          onPageSizeChange(pageSize){
            this.getStaffList({
              'search':this.search,
              'currentPage':this.staff_current_page,
              'pageSize':pageSize*1
            });
          },
          toSearch(){
            this.getStaffList({
              'search':this.search,
              'currentPage':this.staff_current_page,
              'pageSize':this.staff_page_size
            });
          },
          toUpdate(id){
            toGet('/human-resources/hr/staff/queryOne/'+id)
              .then(res=>{
                if (res.resultCode === 0) {
                  this.addForm=res.data;
                  this.updateDrawer=true;
                }else{
                  this.$Notice.warning({
                    title: '获取员工档案信息失败',
                    desc: '服务器发生未知错误'
                  });
                }
              });

          },
          toDel(id){
            swal({
              title: "您确定删除该员工档案吗?",
              text: "删除该员工档案后，系统将删除该员工档案的所有信息!",
              icon: "warning",
              buttons: ["容我再想想!", "确认删除!"],
              dangerMode: true,
            })
              .then((willDelete) => {
                if (willDelete) {
                  toGet('/human-resources/hr/staff/delete/'+id)
                    .then(res=>{
                      if (res.resultCode === 0) {
                        swal("删除成功!", {
                          icon: "success",
                        });
                        this.getStaffList({
                          'search':this.search,
                          'currentPage':1,
                          'pageSize':20
                        });
                      }
                    })
                    .catch(error=>{
                      swal("删除失败!", {
                        icon: "error",
                      });
                    });
                }
              });
          }
        },
        mounted() {
          this.getStaffList({
            'search':'',
            'currentPage':1,
            'pageSize':20
          });
          this.getPostSetList({
            'search':'',
            'currentPage':1,
            'pageSize':999
          })
        }
    }
</script>

<style lang="css" scoped>
  .expand-row{
    margin-bottom: 6px;
  }
</style>
